package behavior.observe;

/**
 * Created by lie on 2017/11/2.
 */
public class Test {
    public static void main(String[] args){
        //搞几个用户
        WxUser wxUser1 = new WxUser("马云");
        WxUser wxUser2 = new WxUser("马化腾");
        WxUser wxUser3 = new WxUser("玛里苟斯");

        //发起订阅
        WeChatSubject weChatSubject = new WeChatSubject();
        weChatSubject.attach(wxUser1);
        weChatSubject.attach(wxUser2);
        weChatSubject.attach(wxUser3);

        //发起更新
        weChatSubject.notify("今天世界毁灭了");

        //不告诉给马云知道了
        weChatSubject.detach(wxUser1);
        weChatSubject.notify("刚刚的消息已辟谣");
    }
}
